use Modern::Perl;
use Net::OpenSSH;
use Test::More;


if ($ENV{ssh_user} && $ENV{ssh_password}){
  my $host = "192.168.4.13";
  my %opt = (
    user=>$ENV{ssh_user},
    password=>$ENV{ssh_password},
    port=>2200,
  );
  my $ssh = Net::OpenSSH->new($host,%opt);
  $ssh->error and die "Can't ssh to $host: " . $ssh->error;
  if ($ssh->error){
    note "ssh ok";
  }else{
    note "ssh no ok";
  }
  note $ssh->get_user;
  note $ssh->get_host;
  note $ssh->get_port;
  note $ssh->get_ctl_path;
  # 测试system命令
  my @data=('test',1,2,3);my $ssh_stdout;
  #$ssh->system('ls /') or die "ls failed: ".$ssh->error;
  $ssh->system({stdout_fh=>$ssh_stdout},'ls /');
  #$ssh->system({stdin_data=>\@data},"cat >/workdir/staff/bixichao/Net::OpenSSH/1.file");
}else{
  print "请在SHELL环境中添加ssh_user和ssh_password变量\n";
}
